<% layout('/layouts/default.html', {title: '考试会员管理管理', libs: ['validate']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header with-border">
			<div class="box-title">
				<i class="fa icon-note"></i> ${text(texaminationVip.isNewRecord ? '新增考试会员管理' : '编辑考试会员管理')}
			</div>
			<div class="box-tools pull-right">
				<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
			</div>
		</div>
		<#form:form id="inputForm" model="${texaminationVip}" action="${ctx}/zx/examination/vip/texaminationVip/save" method="post" class="form-horizontal">
			<div class="box-body">
				<div class="form-unit">${text('基本信息')}</div>
				<#form:hidden path="id"/>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required">*</span> ${text('考试名称')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
							<#form:select path="examId" maxlength="255" onChange="areaChanged('#room')" readonly="${!texaminationVip.isNewRecord}" items="${texaminateList}" itemLabel="objName" itemValue="id" blankOption="true" class="form-control required select2"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required">*</span> ${text('会员标识')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
							<#form:select path="vipUser" maxlength="255"  items="${userVipList}" itemLabel="userName" itemValue="userCode" blankOption="true" class="form-control required select2"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required">*</span> ${text('考场')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
							<#form:select path="room" items="${roomList}" onChange="sceneChanged('#scene')"
									 itemLabel="roomName" itemValue="id" blankOption="true" class="form-control required select2"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required">*</span> ${text('场次')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
							<#form:select path="scene" items="${sceneList}"
									 itemLabel="sceneName" itemValue="id" blankOption="true" class="form-control required select2"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
				    <div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('准考证标识')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="ticketId" readonly="true" maxlength="50" class="form-control"/>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="box-footer">
				<div class="row">
					<div class="col-sm-offset-2 col-sm-10">
						<% if (hasPermi('zx:examination:vip:texaminationVip:edit')){ %>
							<button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i> ${text('保 存')}</button>&nbsp;
						<% } %>
						<button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('关 闭')}</button>
					</div>
				</div>
			</div>
		</#form:form>
	</div>
</div>
<% } %>
<script>
$("#inputForm").validate({
	submitHandler: function(form){
		js.ajaxSubmitForm($(form), function(data){
			js.showMessage(data.message);
			if(data.result == Global.TRUE){
				js.closeCurrentTabPage(function(contentWindow){
					contentWindow.page();
				});
			}
		}, "json");
    }
});
function areaChanged(target){	
	var examId=$('#examId').val();
	$.ajax({
		type:"post",
		async:true,
		url:'${ctx}/zx/examination/room/texaminationRoom/findList',
		data:{
		  'examId':examId		  
		},
		dataType:'json',
		success:function(msg){
			 $(target).empty();
			if(msg.length > 0){
				for(var i=0;i<msg.length;i++){
					var partId=msg[i].id;
					var partName=msg[i].roomName;
					var option=$("<option>").attr({
						"value":partId
					}).text(partName);
					$(target).append(option);
				}
			    $(target+" option:first").prop("selected","selected");
				$(target).change();
			}
		},
		error:function(json){
			alert("操作异常");
		}
	})
}
function sceneChanged(target){
	var examId=$('#examId').val();
	var room=$('#room').val();
	$.ajax({
		type:"post",
		async:true,
		url:'${ctx}/zx/examination/room/scene/texaminationRoomScene/findList',
		data:{
		  'examId':examId,
		  'roomId':room
		},
		dataType:'json',
		success:function(msg){
			 $(target).empty();
			if(msg.length > 0){
				for(var i=0;i<msg.length;i++){
					var partId=msg[i].id;
					var partName=msg[i].sceneName;
					var option=$("<option>").attr({
						"value":partId
					}).text(partName);
					$(target).append(option);
				}
			    $(target+" option:first").prop("selected","selected");
				
			}
		},
		error:function(json){
			alert("操作异常");
		}
	})
}
</script>